/*
  EOMono
  Copyright 2007, Adam Tauno Williams (Whitemice Consulting)
  License: LGPLv2  < http://www.gnu.org/licenses/lgpl-2.1.html >
 */
using System;
using System.Collections;
using System.Collections.Generic;

namespace Whitemice.EOMono
{
  public class EOSQLEntity : EOEntity
  { 
    public EOSQLEntity(string name, bool magicPrimaryKey)
      : base(name, magicPrimaryKey, null)
    {
    }
    
    public EOSQLEntity(string name, bool magicPrimaryKey, string internalName)
      : base(name, magicPrimaryKey, internalName)
    {
    }  
        
    public override IEORecord NewRecord(IEOConnection _connection)
    {
      return new EOSQLRecord(_connection, this, false);
    }
    
    internal override string InternalName
    { 
      get 
      { 
        if (Parameters.Count > 0)
          return string.Format("TABLE({0}({1}))", Name, ParametersAsCSV());
        if (internalName == null)
          return Name;
        return internalName;
      } 
    }    
  }
}
